// Drummer Server
// by Andrea Bianchi
// drummer.alsoplantsfly.com


// Made with PROCESSING 0135 on Intel Mac, Mac OS X 10.5.6


/*
Copyright (C) 2009, Andrea Bianchi

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/



// INSTRUMENT MIDI-MAPPING
// CHANGE HERE IF YOU WANT TO USE OTHER INSTRUMENTS: NUMBERS CORRESPOND TO MIDI INSTRUMENTS
public interface MidiInstruments {
  int BASS1=35;
  int BASS2= 36;
  int HIHAT1= 44;
  int HIHAT2= 46;
  int SNARE1= 38;
  int SNARE2= 39;
  int CRASH1= 49;
  int CRASH2= 51;
  int TOM1= 41;
  int TOM2= 43;
  int TOM3= 45;
  int TOM4= 47;
}



// START CODE ENTRY POINT HERE

PImage backgroundImg;
DrummerNetwork netw;
DrummerMidi midi;

void setup(){
  size(256,192);
  smooth();

  backgroundImg= loadImage("bg.jpg"); 

  midi = new DrummerMidi(this);
  netw= new DrummerNetwork (this, midi);  
}

void draw(){
  if (netw.isInitialized())
  {
    netw.update();
    fill(0,255,0);
  }
  else{
    fill(255,0,0);
  }

  image(backgroundImg,0,0);
  // magic numbers ;)
  ellipse (13,179,10,10);
}


void mousePressed()
{
  if (!netw.isInitialized())
    new PortForm();
  else
    netw.stopNetwork();
}
